﻿using System;
using System.IO.Ports;
using System.Threading;
using System.Windows.Forms;

namespace sistem
{
    public class SMS
    {
        private SerialPort _serialPort = new SerialPort("COM7, 115200");
        public void PosaljiSMS(Cas cas, Ucenik ucenik)
        {
            string number = "062417023";
            string message = "Poštvani, učenik taj i taj je tog i tog dana dobio tu i tu ocjenu.";

            Thread.Sleep(1000);

            _serialPort.Open();

            Thread.Sleep(1000);

            _serialPort.Write("AT+CMGF=1\r");

            Thread.Sleep(1000);

            _serialPort.Write("AT+CMGS=\"" + number + "\"\r\n");

            Thread.Sleep(1000);

            _serialPort.Write(message + "\x1A");

            Thread.Sleep(1000);

            MessageBox.Show("Poruka je poslana!", "Poruka", MessageBoxButtons.OK, MessageBoxIcon.Information);

            _serialPort.Close();
        }
    }
}
